home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / thenet / x1j4_src / thenet1.mac < prev    next >
Encoding:
Text File  |  1995-03-01  |  7.4 KB  |  395 lines

  1. ;
  2. ; This module is designed to provide the bank switching interface
  3. ; when thenet is split into 3 chunks.
  4. ;
  5. ; The assumption is that the interrupt bits etc are
  6. ; stored in rom from  0-115f
  7. ; level 2, 3 & 4 from 1160-7fff for one page
  8. ; level 7        from 1160-7fff for the other page
  9. ;
  10. ;
  11. ; Also, define Fremem to define the first free byte in RAM
  12.  
  13. ; released as thenet x-1j september 1993
  14. ; heavily modified for PK96 ( 64180 ) and X1J release 4
  15.  
  16.     .64180
  17. ;
  18. ; this first section is patched with addresses from the linker
  19. ; symbol table
  20. ;
  21. mainf    equ    10e0h    ; l7a
  22. l2tol7    equ    1db8h    ; l7a
  23. fmlink    equ    20e1h    ; l7a
  24. notify    equ    3ceeh   ; l7
  25. acl_entry equ    4519h    ; l7b2
  26. iswarm    equ    4f38h    ; l7c
  27. fvalca    equ    5dd9h    ; l7u
  28. arp_add equ    6c92h    ; tnl7ip.c
  29. ;
  30. l2    equ    10e0h    ; l2
  31. l2timr    equ    1a8ch    ; l2
  32. chknoa    equ    1d26h    ; l2
  33. newlnk    equ    1d78h    ; l2
  34. dsclnk    equ    1daah    ; l2
  35. itolnk    equ    1e18h    ; l2
  36. sdui    equ    265dh    ; l2
  37. cpyidl    equ    2ee5h    ; l2
  38. cpyid    equ    2f25h    ; l2
  39. dealml    equ    2f59h    ; l2
  40. dealmb    equ    2f89h    ; l2
  41. dealoc    equ    2fbch    ; l2
  42. inithd    equ    3003h    ; l2
  43. l2init    equ    3041h    ; l2
  44. ;
  45. l3init    equ    3270h    ; l3
  46. l3serv    equ    33adh    ; l3
  47. brosrv    equ    3b42h    ; l3
  48. chgnod    equ    3de2h    ; l3
  49. updnbr    equ    46f2h    ; l3
  50. getnei    equ    479ah    ; l3
  51. iscall    equ    485fh    ; l3
  52. isidnt    equ    48aah    ; l3
  53. initl4    equ    4a26h    ; l4
  54. l4serv    equ    4ac1h    ; l4
  55. trasrv    equ    5340h    ; l4
  56. newcir    equ    54f2h    ; l4
  57. discir    equ    551ch    ; l4
  58. itocir    equ    5583h    ; l4
  59. ipinit    equ    5e39h    ; ip router
  60. ipserv    equ    5ed0h    ; ip router
  61. ip_mask    equ    74fdh    ; ip router
  62. ;
  63.  
  64. BBR    equ    039h+0c0h
  65.         extrn   kick_wdog_
  66. ;
  67. ;
  68.     global    pgflag, 1
  69.  
  70.     cseg
  71. ;
  72. ; declare these so the linker causes the pages to call the bank switch
  73. ; versions
  74. ;
  75.     public fvalca_
  76.     public fmlink_
  77.     public l2tol7_
  78.     public iswarm_
  79.     public mainf_
  80.     public iscall_
  81.     public initl4_
  82.     public l3init_
  83.     public l3serv_
  84.     public l4serv_
  85.     public brosrv_
  86.     public trasrv_
  87.     public discir_
  88.     public itocir_
  89.     public isidnt_
  90.     public newcir_
  91.     public chgnod_
  92.     public getnei_
  93.     public updnbr_
  94.     public acl_entry_
  95.     public ipinit_
  96.     public ipserv_
  97.     public ip_mask_
  98.  
  99.     public l2init_
  100.     public l2_
  101.     public inithd_
  102.     public cpyid_
  103.     public l2timr_
  104.     public chknoa_
  105.     public dealmb_
  106.     public dsclnk_
  107.     public itolnk_
  108.     public sdui_
  109.     public cpyidl_
  110.     public newlnk_
  111.     public dealoc_
  112.     public dealml_
  113.     public notify_
  114.     public arp_add_
  115.  
  116. ; the following is just to keep the linker happy
  117. ;
  118.     public .ovbgn
  119.  
  120. ; One call for each routine. There are two types of routine.
  121. ; One with parameters  and one without. For space reasons we
  122. ; use a common routine for each.
  123. ;
  124. iswarm_: call kick_wdog_
  125.         call setpag1
  126.     jp iswarm
  127.  
  128. mainf_:    
  129.     ld a,7
  130.     out0 (BBR),a
  131.     ld a,1
  132.     ld (pgflag),a
  133.     jp mainf
  134.  
  135. initl4_: call setpag2
  136.     jp initl4
  137.  
  138. l3init_: call setpag2
  139.     jp l3init
  140.  
  141. l3serv_: call setpag2
  142.     jp l3serv
  143.  
  144. l4serv_: call setpag2
  145.     jp l4serv
  146.  
  147. brosrv_: call setpag2
  148.     jp brosrv
  149.  
  150. trasrv_: call setpag2
  151.     jp trasrv
  152.  
  153. discir_: call setpag2
  154.     jp discir
  155.  
  156. newcir_: call setpag2
  157.     jp newcir
  158.  
  159. l2init_: call setpag2
  160.     jp l2init
  161.  
  162. l2_:     call setpag2
  163.     jp l2
  164.  
  165. chknoa_: call setpag2
  166.     jp chknoa
  167.  
  168. dsclnk_: call setpag2
  169.     jp dsclnk
  170.  
  171. newlnk_: call setpag2
  172.     jp newlnk
  173.  
  174. ipinit_: call setpag2
  175.     jp ipinit
  176.  
  177. ipserv_: call setpag2
  178.     jp ipserv
  179.  
  180. acl_entry_: ld de, 01feh
  181.     call setbsf
  182.     call acl_entry
  183.     jr bankexit1
  184.  
  185. sdui_: ld de, 02f6h
  186.     call setbsf
  187.     call sdui
  188.     jr bankexit5
  189.  
  190. cpyidl_: ld de, 02fch
  191.     call setbsf
  192.     call cpyidl
  193.     jr bankexit2
  194.  
  195. dealoc_: ld de, 02feh
  196.     call setbsf
  197.     call dealoc
  198.     jr bankexit1
  199.  
  200. dealml_: ld de, 02feh
  201.     call setbsf
  202.     call dealml
  203.     jr bankexit1
  204.  
  205. notify_: ld de, 01f4h
  206.     call setbsf
  207.     call notify
  208.     jr bankexit6
  209.  
  210. arp_add_: ld de, 01f4h
  211.     call setbsf
  212.     call arp_add
  213.     jr bankexit6
  214.  
  215. fvalca_: ld de, 01fch
  216.     call setbsf
  217.     call fvalca
  218.     jr bankexit2
  219.  
  220. fmlink_: ld de, 01fch
  221.     call setbsf
  222.     call fmlink
  223.     jr bankexit2
  224.  
  225. l2tol7_: ld de, 01fah
  226.     call setbsf
  227.     call l2tol7
  228.     jr bankexit3
  229.  
  230. iscall_: ld de, 02feh
  231.     call setbsf
  232.     call iscall
  233.     jr bankexit1
  234.  
  235. bankexit8: pop de
  236. bankexit7: pop de
  237. bankexit6: pop de
  238. bankexit5: pop de
  239. bankexit4: pop de
  240. bankexit3: pop de
  241. bankexit2: pop de
  242. bankexit1: pop de
  243.            pop bc
  244. bankexit0:
  245.     ex (sp),hl    ; get previous bankswitch state & save hl
  246.     push af        ; save A whilst we do it
  247.     ld a,h
  248.     ld (pgflag),a    ; reinstate bankswitch state
  249.     call bankctrl
  250.     pop af        ; now reinstate A
  251.     ex (sp),hl    ; reinstate hl
  252.     inc sp        ; correct the stack pointer
  253.     inc sp
  254.     ret
  255.  
  256. itocir_: ld de, 02fch
  257.     call setbsf
  258.     call itocir
  259.     jr bankexit2
  260.  
  261. isidnt_: ld de, 02feh
  262.     call setbsf
  263.     call isidnt
  264.     jr bankexit1
  265.  
  266. chgnod_: ld de, 02f0h
  267.     call setbsf
  268.     call chgnod
  269.     jr bankexit8
  270.  
  271. getnei_: ld de, 02fah
  272.     call setbsf
  273.     call getnei
  274.     jr bankexit3
  275.  
  276. updnbr_: ld de, 02fah
  277.     call setbsf
  278.     call updnbr
  279.     jr bankexit3
  280.  
  281. inithd_: ld de, 02feh
  282.     call setbsf
  283.     call inithd
  284.     jr bankexit1
  285.  
  286. cpyid_: ld de, 02fch
  287.     call setbsf
  288.     call cpyid
  289.     jr bankexit2
  290.  
  291. l2timr_: ld de, 02feh
  292.     call setbsf
  293.     call l2timr
  294.     jr bankexit1
  295.  
  296. dealmb_: ld de, 02feh
  297.     call setbsf
  298.     call dealmb
  299.     jr bankexit1
  300.  
  301. itolnk_: ld de, 02fch
  302.     call setbsf
  303.     call itolnk
  304.     jr bankexit2
  305.  
  306. ip_mask_: ld de, 02fch
  307.     call setbsf
  308.     call ip_mask
  309.     jp bankexit2
  310. ;
  311. ; this is the entry routine for calls that take parameters.
  312. ; It is passed a single parameter in the DE register. D tells
  313. ; it the bank to switch to ( 1 or 2 ). E tells it how many
  314. ; bytes of parameter data to copy, so a value of 0xfc would
  315. ; copy 4 bytes, ie 2 parameters. It is coded as a negative
  316. ; number to make the code quicker.
  317. ;
  318. setbsf:    pop hl        ; pull return address
  319.     ld a,(pgflag)    ; save current bank switch value on stack
  320.     push af
  321.     ld a,d        ; get new bank value
  322.     ld (pgflag),a    ; and save it as current bank
  323.     call bankctrl    ; and switch bank
  324.     ld d,0ffh    ; convert E to signed double signed DE
  325.     push bc        ; save BC. Reinstate in bankexit().
  326.     ld a,e        ; save byte count for copy routine
  327.     ex de,hl    ; put byte offset into hl
  328.     add hl,sp    ; drop stack pointer this many bytes
  329.     ld sp,hl
  330.     push de        ; 
  331.     cpl        ; make byte count positive in A
  332.     push af        ; preserve for byte copy
  333.     add a,7        ; add 7 to step over stacked stuff
  334.     ld e,a
  335.     ld d,0
  336.     ex de,hl
  337.     add hl,de    ; hl now pointer to data to be copied
  338.     pop af        ; bump count to get it correct
  339.     inc a
  340.     ld b,0
  341.     ld c,a
  342.     ldir        ; make a copy of parameters
  343. .ovbgn:    ret
  344.  
  345. ; The setpag1 and setpag2 routines are used for calls that
  346. ; do not have parameters. They are used to switch to pages
  347. ; 1 and 2 respectively
  348. ;
  349. setpag1: ld     d,1
  350.      jr     setpag
  351. setpag2: ld    d,2
  352. ;
  353. setpag:    pop    hl        ; get return address off stack
  354.     ld    a,(pgflag)    ; save bank select info in stack
  355.     push    af
  356.     ld    a,d        ; get desired memory bank select
  357.     ld    (pgflag),a
  358.     call    bankctrl    ; set bank select registers
  359.     ld    de,bankexit0
  360.     push    de        ; simulate a return address of bankexit0()
  361.     jp    (hl)
  362. ;
  363. ; This routine sets the bank control register.
  364. ; if A equals 1, set bank 1 ie output a zero to the control bit to
  365. ; select lower half of eprom.
  366. ; if A equals 2, ie if bit zero is 0, output a 1 to select upper half
  367. ;
  368. ; WARNING - if you change this, also change mainf_ function above
  369. ;
  370.     extrn    DIinc_, decEI_
  371.  
  372. bankctrl: 
  373. ;    push    hl
  374. ;    call    DIinc_        ; turn off interrupts
  375.     and    1        ; see if bit 0 is set ( bank == 1 or 2 )
  376.     jr    nz,bctrl0
  377.     xor    a
  378.     jr    bctrl1
  379. bctrl0:    ld    a,7
  380. bctrl1:    out0    (BBR),a
  381. ;    call    decEI_        ; turn on ints - ONLY IF they were on before.
  382. ;    pop    hl
  383.     ret
  384.  
  385.     dseg
  386. ;
  387. ; record top of RAM
  388. ;
  389.     extrn    _Uend_
  390.     public    Fremem_
  391. Fremem_: 
  392.     dw     _Uend_
  393.  
  394.     end
  395.